package cn.wolfcode.trip.app.controller;

import cn.wolfcode.trip.app.util.UserContext;
import cn.wolfcode.trip.base.domain.Answer;
import cn.wolfcode.trip.base.domain.CommunityComment;
import cn.wolfcode.trip.base.domain.User;
import cn.wolfcode.trip.base.service.IAnswerService;
import cn.wolfcode.trip.base.service.ICommunityCommentService;
import cn.wolfcode.trip.base.util.JasonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/communityComments")
public class CommunityCommentController {
    @Autowired
    private ICommunityCommentService communityCommentService;

    @PostMapping
    public Object saveComment(CommunityComment comment) {
        User currentUser = UserContext.getCurrentUser();
        comment.setUserId(currentUser.getId());
        //保存评论内容
        communityCommentService.saveComment(comment);
        return new JasonResult();
    }

}
